home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / GCC 1.37.1r14 / usr / gcc-1.37.1r14 / (gcc-1.37.π) / toplev.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-17  |  57.7 KB  |  1,829 lines  |  [TEXT/KAHL]

  1. /* Top level of GNU C compiler
  2.    Copyright (C) 1987, 1988, 1989 Free Software Foundation, Inc.
  3.    Copyright (C) 1989, 1990 Apple Computer, Inc.
  4.  
  5. This file is part of GNU CC.
  6.  
  7. GNU CC is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 1, or (at your option)
  10. any later version.
  11.  
  12. GNU CC is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with GNU CC; see the file COPYING.  If not, write to
  19. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21.  
  22. /* This is the top level of cc1.
  23.    It parses command args, opens files, invokes the various passes
  24.    in the proper order, and counts the time used by each.
  25.    Error messages and low-level interface to malloc also handled here.  */
  26.  
  27. #include "config.h"
  28. #include <stdio.h>
  29. #include <signal.h>
  30. #include <setjmp.h>
  31.  
  32. #ifdef MPW
  33. /* MPW has its include files in slightly different places than Unix. */
  34. #include <types.h>
  35. #else
  36. #include <sys/types.h>
  37. #include <sys/stat.h>
  38. #endif /* MPW */
  39.  
  40. #ifdef MPW
  41. #ifdef PERFORMANCE
  42. #include <Perf.h>
  43. #endif /* PERFORMANCE */
  44. #else /* not MPW */
  45. #ifdef USG
  46. #undef FLOAT
  47. #include <sys/param.h>
  48. /* This is for hpux.  It is a real screw.  They should change hpux.  */
  49. #undef FLOAT
  50. #include <sys/times.h>
  51. #include <time.h>   /* Correct for hpux at least.  Is it good on other USG?  */
  52. #undef FFS  /* Some systems define this in param.h.  */
  53. #else
  54. #ifndef VMS
  55. #include <sys/time.h>
  56. #include <sys/resource.h>
  57. #endif
  58. #endif
  59. #endif /* MPW */
  60.  
  61. #include "input.h"
  62. #include "tree.h"
  63. #include "c-tree.h"
  64. #include "rtl.h"
  65. #include "flags.h"
  66.  
  67. extern int yydebug;
  68.  
  69. extern FILE *finput;
  70.  
  71. extern int reload_completed;
  72. extern int rtx_equal_function_value_matters;
  73.  
  74. extern void init_lex ();
  75. extern void init_decl_processing ();
  76. extern void init_tree ();
  77. extern void init_rtl ();
  78. extern void init_optabs ();
  79. extern void init_reg_sets ();
  80. extern void dump_flow_info ();
  81. extern void dump_local_alloc ();
  82.  
  83. void rest_of_decl_compilation ();
  84. void error ();
  85. void error_with_file_and_line ();
  86. void fancy_abort ();
  87. void set_target_switch ();
  88. void print_target_switch_defaults ();
  89.  
  90. /* Bit flags that specify the machine subtype we are compiling for.
  91.    Bits are tested using macros TARGET_... defined in the tm-...h file
  92.    and set by `-m...' switches.  */
  93.  
  94. int target_flags;
  95.  
  96. /* Name of current original source file (what was input to cpp).
  97.    This comes from each #-command in the actual input.  */
  98.  
  99. char *input_filename;
  100.  
  101. /* Name of top-level original source file (what was input to cpp).
  102.    This comes from the #-command at the beginning of the actual input.
  103.    If there isn't any there, then this is the cc1 input file name.  */
  104.  
  105. char *main_input_filename;
  106.  
  107. /* Current line number in real source file.  */
  108.  
  109. extern int lineno;
  110.  
  111. /* Stack of currently pending input files.  */
  112.  
  113. struct file_stack *input_file_stack;
  114.  
  115. /* Incremented on each change to input_file_stack.  */
  116. int input_file_stack_tick;
  117.  
  118. /* FUNCTION_DECL for function now being parsed or compiled.  */
  119.  
  120. extern tree current_function_decl;
  121.  
  122. /* Name to use as base of names for dump output files.  */
  123.  
  124. char *dump_base_name;
  125.  
  126. /* Flags saying which kinds of debugging dump have been requested.  */
  127.  
  128. int rtl_dump = 0;
  129. int rtl_dump_and_exit = 0;
  130. int jump_opt_dump = 0;
  131. int cse_dump = 0;
  132. int loop_dump = 0;
  133. int flow_dump = 0;
  134. int combine_dump = 0;
  135. int local_reg_dump = 0;
  136. int global_reg_dump = 0;
  137. int jump2_opt_dump = 0;
  138. int dbr_sched_dump = 0;
  139.  
  140. /* 1 => write gdb debugging output (using symout.c).  -g
  141.    2 => write dbx debugging output (using dbxout.c).  -G
  142.    3 => write sdb debugging output (using sdbout.c).  -g.  */
  143.  
  144. enum debugger write_symbols = NO_DEBUG;
  145.  
  146. /* Nonzero means can use our own extensions to DBX format.
  147.    Relevant only with write_symbols == DBX_DEBUG.  */
  148.  
  149. int use_gdb_dbx_extensions;
  150.  
  151. /* Nonzero means do optimizations.  -opt.  */
  152.  
  153. int optimize = 0;
  154.  
  155. /* Nonzero means `char' should be signed.  */
  156.  
  157. int flag_signed_char;
  158.  
  159. /* Nonzero means give an enum type only as many bytes as it needs.  */
  160.  
  161. int flag_short_enums;
  162.  
  163. /* Nonzero for -fcaller-saves: allocate values in regs that need to
  164.    be saved across function calls, if that produces overall better code.
  165.    Optional now, so people can test it.  */
  166.  
  167. #ifdef DEFAULT_CALLER_SAVES
  168. int flag_caller_saves = 1;
  169. #else
  170. int flag_caller_saves = 0;
  171. #endif
  172.  
  173. /* Nonzero for -fpcc-struct-return: return values the same way PCC does.  */
  174.  
  175. int flag_pcc_struct_return = 0;
  176.  
  177. /* Nonzero for -fforce-mem: load memory value into a register
  178.    before arithmetic on it.  This makes better cse but slower compilation.  */
  179.  
  180. int flag_force_mem = 0;
  181.  
  182. /* Nonzero for -fforce-addr: load memory address into a register before
  183.    reference to memory.  This makes better cse but slower compilation.  */
  184.  
  185. int flag_force_addr = 0;
  186.  
  187. /* Nonzero for -fdefer-pop: don't pop args after each function call;
  188.    instead save them up to pop many calls' args with one insns.  */
  189.  
  190. int flag_defer_pop = 1;
  191.  
  192. /* Nonzero for -ffloat-store: don't allocate floats and doubles
  193.    in extended-precision registers.  */
  194.  
  195. int flag_float_store = 0;
  196.  
  197. /* Nonzero for -fcombine-regs:
  198.    allow instruction combiner to combine an insn
  199.    that just copies one reg to another.  */
  200.  
  201. int flag_combine_regs = 0;
  202.  
  203. /* Nonzero enables strength-reduction in loop.c.  */
  204.  
  205. int flag_strength_reduce = 0;
  206.  
  207. /* Nonzero for -fwritable-strings:
  208.    store string constants in data segmentand don't uniquize them.  */
  209.  
  210. int flag_writable_strings = 0;
  211.  
  212. /* Nonzero means don't put addresses of constant functions in registers.
  213.    Used for compiling the Unix kernel, where strange substitutions are
  214.    done on the assembly output.  */
  215.  
  216. int flag_no_function_cse = 0;
  217.  
  218. /* Nonzero for -fomit-frame-pointer:
  219.    don't make a frame pointer in simple functions that don't require one.  */
  220.  
  221. int flag_omit_frame_pointer = 0;
  222.  
  223. /* Nonzero to inhibit use of define_optimization peephole opts.  */
  224.  
  225. int flag_no_peephole = 0;
  226.  
  227. /* Nonzero means all references through pointers are volatile.  */
  228.  
  229. int flag_volatile;
  230.  
  231. /* Nonzero means just do syntax checking; don't output anything.  */
  232.  
  233. int flag_syntax_only = 0;
  234.  
  235. /* Nonzero means do stupid register allocation.  -noreg.
  236.    This and `optimize' are controlled by different switches in cc1,
  237.    but normally cc controls them both with the -O switch.  */
  238.  
  239. int obey_regdecls = 0;
  240.  
  241. /* Don't print functions as they are compiled and don't print
  242.    times taken by the various passes.  -quiet.  */
  243.  
  244. int quiet_flag = 0;
  245.  
  246. /* Don't print warning messages.  -w.  */
  247.  
  248. int inhibit_warnings = 0;
  249.  
  250. /* Do print extra warnings (such as for uninitialized variables).  -W.  */
  251.  
  252. int extra_warnings = 0;
  253.  
  254. /* Nonzero to warn about unused local variables.  */
  255.  
  256. int warn_unused;
  257.  
  258. /* Nonzero means warn about all declarations which shadow others.   */
  259.  
  260. int warn_shadow;
  261.  
  262. /* Warn if a switch on an enum fails to have a case for every enum value.  */
  263.  
  264. int warn_switch;
  265.  
  266. /* Nonzero means warn about any identifiers that match in the first N
  267.    characters.  The value N is in `id_clash_len'.  */
  268.  
  269. int warn_id_clash;
  270. int id_clash_len;
  271.  
  272. /* Number of error messages and warning messages so far.  */
  273.  
  274. int errorcount = 0;
  275. int warningcount = 0;
  276. int sorrycount = 0;
  277.  
  278. /* Name of program invoked, sans directories.  */
  279.  
  280. char *progname;
  281.  
  282. /* Nonzero if generating code to do profiling.  */
  283.  
  284. int profile_flag = 0;
  285.  
  286. /* Nonzero if generating code to do profiling on a line-by-line basis.  */
  287.  
  288. int profile_block_flag;
  289.  
  290. /* Nonzero for -pedantic switch: warn about anything
  291.    that standard spec forbids.  */
  292.  
  293. int pedantic = 0;
  294.  
  295. /* Nonzero for -finline-functions: ok to inline functions that look like
  296.    good inline candidates.  */
  297.  
  298. int flag_inline_functions;
  299.  
  300. /* Nonzero for -fkeep-inline-functions: even if we make a function
  301.    go inline everywhere, keep its defintion around for debugging
  302.    purposes.  */
  303.  
  304. int flag_keep_inline_functions;
  305.  
  306. /* Nonzero means make the text shared if supported.  */
  307.  
  308. int flag_shared_data;
  309.  
  310. /* Nonzero means schedule into delayed branch slots if supported.  */
  311.  
  312. int flag_delayed_branch;
  313.  
  314. /* Copy of arguments to main.  */
  315. int save_argc;
  316. char **save_argv;
  317.  
  318. /* Name for output file of assembly code, specified with -o.  */
  319.  
  320. char *asm_file_name;
  321.  
  322. /* Name for output file of GDB symbol segment, specified with -symout.  */
  323.  
  324. char *sym_file_name;
  325.  
  326. #ifdef APPLE_C
  327. /* Segment name for Macintosh. */
  328.  
  329. char *segment_name = "Main";
  330.  
  331. /* Flag indicating whether tracing is to happen. */
  332.  
  333. int generate_trace_calls = 0;
  334.  
  335. /* Flag indicating whether #pragma trace affects tracing. */
  336.  
  337. int ignore_trace_pragmas = 0;
  338. #endif /* APPLE_C */
  339.  
  340. #ifdef MPW
  341. #ifdef PERFORMANCE
  342. TP2PerfGlobals ThePGlobals;
  343. #endif /* PERFORMANCE */
  344. #endif /* MPW */
  345.  
  346. /* Table of language-independent -f options.
  347.    STRING is the option name.  VARIABLE is the address of the variable.
  348.    ON_VALUE is the value to store in VARIABLE
  349.     if `-fSTRING' is seen as an option.
  350.    (If `-fno-STRING' is seen as an option, the opposite value is stored.)  */
  351.  
  352. struct { char *string; int *variable; int on_value;} f_options[] =
  353. {
  354.   {"float-store", &flag_float_store, 1},
  355.   {"volatile", &flag_volatile, 1},
  356.   {"defer-pop", &flag_defer_pop, 1},
  357.   {"omit-frame-pointer", &flag_omit_frame_pointer, 1},
  358.   {"strength-reduce", &flag_strength_reduce, 1},
  359.   {"writable-strings", &flag_writable_strings, 1},
  360.   {"peephole", &flag_no_peephole, 0},
  361.   {"force-mem", &flag_force_mem, 1},
  362.   {"force-addr", &flag_force_addr, 1},
  363.   {"combine-regs", &flag_combine_regs, 1},
  364.   {"function-cse", &flag_no_function_cse, 0},
  365.   {"inline-functions", &flag_inline_functions, 1},
  366.   {"keep-inline-functions", &flag_keep_inline_functions, 1},
  367.   {"syntax-only", &flag_syntax_only, 1},
  368.   {"shared-data", &flag_shared_data, 1},
  369.   {"caller-saves", &flag_caller_saves, 1},
  370.   {"pcc-struct-return", &flag_pcc_struct_return, 1},
  371.   {"delayed-branch", &flag_delayed_branch, 1}
  372. };
  373.  
  374. /* Output files for assembler code (real compiler output)
  375.    and debugging dumps.  */
  376.  
  377. FILE *asm_out_file;
  378. FILE *rtl_dump_file;
  379. FILE *jump_opt_dump_file;
  380. FILE *cse_dump_file;
  381. FILE *loop_dump_file;
  382. FILE *flow_dump_file;
  383. FILE *combine_dump_file;
  384. FILE *local_reg_dump_file;
  385. FILE *global_reg_dump_file;
  386. FILE *jump2_opt_dump_file;
  387. FILE *dbr_sched_dump_file;
  388.  
  389. /* Time accumulators, to count the total time spent in various passes.  */
  390.  
  391. int parse_time;
  392. int varconst_time;
  393. int integration_time;
  394. int jump_time;
  395. int cse_time;
  396. int loop_time;
  397. int flow_time;
  398. int combine_time;
  399. int local_alloc_time;
  400. int global_alloc_time;
  401. int dbr_sched_time;
  402. int final_time;
  403. int symout_time;
  404. int dump_time;
  405.  
  406. /* Return time used so far, in microseconds.  */
  407.  
  408. int
  409. gettime ()
  410. {
  411. #ifdef MPW
  412.   /* don't need a structure here */
  413.  
  414. #else
  415. #ifdef USG
  416.   struct tms tms;
  417. #else
  418. #ifndef VMS
  419.   struct rusage rusage;
  420. #else /* VMS */
  421.   struct
  422.     {
  423.       int proc_user_time;
  424.       int proc_system_time;
  425.       int child_user_time;
  426.       int child_system_time;
  427.     } vms_times;
  428. #endif
  429. #endif
  430. #endif /* MPW */
  431.  
  432.   if (quiet_flag)
  433.     return 0;
  434.  
  435. #ifdef MPW
  436.   /* MPW's returns 1/60 sec ticks, so we do easy conversion to microseconds. */
  437.   return (clock() * (1000000 / 60));
  438. #else
  439. #ifdef USG
  440.   times (&tms);
  441.   return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
  442. #else
  443. #ifndef VMS
  444.   getrusage (0, &rusage);
  445.   return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
  446.       + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
  447. #else /* VMS */
  448.   times (&vms_times);
  449.   return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
  450. #endif
  451. #endif
  452. #endif /* MPW */
  453. }
  454.  
  455. #define TIMEVAR(VAR, BODY)    \
  456. do { int otime = gettime (); BODY; VAR += gettime () - otime; } while (0)
  457.  
  458. void
  459. print_time (str, total)
  460.      char *str;
  461.      int total;
  462. {
  463.   fprintf (stderr,
  464.        "time in %s: %d.%06d\n",
  465.        str, total / 1000000, total % 1000000);
  466. }
  467.  
  468. /* Count an error or warning.  Return 1 if the message should be printed.  */
  469.  
  470. int
  471. count_error (warningp)
  472.      int warningp;
  473. {
  474.   if (warningp && inhibit_warnings)
  475.     return 0;
  476.  
  477.   if (warningp)
  478.     warningcount++;
  479.   else
  480.     errorcount++;
  481.  
  482.   return 1;
  483. }
  484.  
  485. /* Print a fatal error message.  NAME is the text.
  486.    Also include a system error message based on `errno'.  */
  487.  
  488. void
  489. pfatal_with_name (name)
  490.      char *name;
  491. {
  492.   fprintf (stderr, "%s: ", progname);
  493.   perror (name);
  494.   exit (35);
  495. }
  496.  
  497. void
  498. fatal_io_error (name)
  499.      char *name;
  500. {
  501.   fprintf (stderr, "%s: %s: I/O error\n", progname, name);
  502.   exit (35);
  503. }
  504.  
  505. void
  506. fatal (s, v)
  507.      char *s;
  508.      int v;
  509. {
  510.   error (s, v);
  511.   exit (34);
  512. }
  513.  
  514. /* Called from insn-extract to give a better error message when we
  515.    don't have an insn to match what we are looking for, rather
  516.    than just calling abort().  */
  517.  
  518. void
  519. fatal_insn_not_found (insn)
  520.      rtx insn;
  521. {
  522.   error ("The following insn was not recognizable:", 0);
  523.   debug_rtx (insn);
  524.   abort ();
  525. }
  526.  
  527. static int need_error_newline;
  528.  
  529. /* Function of last error message;
  530.    more generally, function such that if next error message is in it
  531.    then we don't have to mention the function name.  */
  532. static tree last_error_function = NULL;
  533.  
  534. /* Used to detect when input_file_stack has changed since last described.  */
  535. static int last_error_tick;
  536.  
  537. /* Called when the start of a function definition is parsed,
  538.    this function prints on stderr the name of the function.  */
  539.  
  540. void
  541. announce_function (decl)
  542.      tree decl;
  543. {
  544.   if (! quiet_flag)
  545.     {
  546.       fprintf (stderr, " %s", DECL_PRINT_NAME (decl));
  547. #ifdef MPW
  548.       /* Newline after function name makes us look more like MPW C. */
  549.       fprintf (stderr, "\n");
  550. #endif /* MPW */
  551.       fflush (stderr);
  552.       need_error_newline = 1;
  553.       last_error_function = current_function_decl;
  554.     }
  555. }
  556.  
  557. /* Prints out, if necessary, the name of the current function
  558.    which caused an error.  Called from all error and warning functions.  */
  559.  
  560. void
  561. report_error_function (file)
  562.      char *file;
  563. {
  564.   struct file_stack *p;
  565.  
  566.   if (need_error_newline)
  567.     {
  568.       fprintf (stderr, "\n");
  569.       need_error_newline = 0;
  570.     }
  571.  
  572.   if (last_error_function != current_function_decl)
  573.     {
  574.       if (file)
  575.     fprintf (stderr, "%s: ", file);
  576.  
  577.       if (current_function_decl == NULL)
  578.     fprintf (stderr, "At top level:\n");
  579.       else if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
  580.     fprintf (stderr, "In method %s:\n",
  581.          DECL_PRINT_NAME (current_function_decl));
  582.       else
  583.     fprintf (stderr, "In function %s:\n",
  584.          DECL_PRINT_NAME (current_function_decl));
  585.  
  586.       last_error_function = current_function_decl;
  587.     }
  588.   if (input_file_stack && input_file_stack->next != 0
  589.       && input_file_stack_tick != last_error_tick)
  590.     {
  591.       fprintf (stderr, "In file included");
  592.       for (p = input_file_stack->next; p; p = p->next)
  593.     {
  594.       fprintf (stderr, " from %s:%d", p->name, p->line);
  595.       if (p->next)
  596.         fprintf (stderr, ",");
  597.     }
  598.       fprintf (stderr, ":\n");
  599.       last_error_tick = input_file_stack_tick;
  600.     }
  601. }
  602.  
  603. /* Report an error at the current line number.
  604.    S and V are a string and an arg for `printf'.  */
  605.  
  606. void
  607. error (s, v, v2)
  608.      char *s;
  609.      int v;            /* @@also used as pointer */
  610.      int v2;            /* @@also used as pointer */
  611. {
  612.   error_with_file_and_line (input_filename, lineno, s, v, v2);
  613. }
  614.  
  615. /* Report an error at line LINE of file FILE.
  616.    S and V are a string and an arg for `printf'.  */
  617.  
  618. void
  619. error_with_file_and_line (file, line, s, v, v2)
  620.      char *file;
  621.      int line;
  622.      char *s;
  623.      int v;
  624.      int v2;
  625. {
  626.   count_error (0);
  627.  
  628.   report_error_function (file);
  629.  
  630.   if (file)
  631. #ifdef MPW
  632.     /* Print file and line so that they're valid MPW commands. */
  633.     fprintf (stderr, "File \"%s\"; Line %d\t# ", file, line);
  634. #else
  635.     fprintf (stderr, "%s:%d: ", file, line);
  636. #endif /* MPW */
  637.   else
  638.     fprintf (stderr, "%s: ", progname);
  639.   fprintf (stderr, s, v, v2);
  640.   fprintf (stderr, "\n");
  641. }
  642.  
  643. /* Report an error at the declaration DECL.
  644.    S and V are a string and an arg which uses %s to substitute the declaration name.  */
  645.  
  646. void
  647. error_with_decl (decl, s, v)
  648.      tree decl;
  649.      char *s;
  650.      int v;
  651. {
  652.   count_error (0);
  653.  
  654.   report_error_function (DECL_SOURCE_FILE (decl));
  655.  
  656. #ifdef MPW
  657.   /* Print file and line so that they're valid MPW commands. */
  658.   fprintf (stderr, "File \"%s\"; Line %d\t# ",
  659. #else
  660.   fprintf (stderr, "%s:%d: ",
  661. #endif /* MPW */
  662.        DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
  663.  
  664.   if (DECL_PRINT_NAME (decl))
  665.     fprintf (stderr, s, DECL_PRINT_NAME (decl), v);
  666.   else if (DECL_NAME (decl))
  667.     fprintf (stderr, s, IDENTIFIER_POINTER (DECL_NAME (decl)), v);
  668.   else
  669.     fprintf (stderr, s, "((anonymous))", v);
  670.   fprintf (stderr, "\n");
  671. }
  672.  
  673. /* Report an error at the line number of the insn INSN.
  674.    S and V are a string and an arg for `printf'.
  675.    This is used only when INSN is an `asm' with operands,
  676.    and each ASM_OPERANDS records its own source file and line.  */
  677.  
  678. void
  679. error_for_asm (insn, s, v, v2)
  680.      rtx insn;
  681.      char *s;
  682.      int v;            /* @@also used as pointer */
  683.      int v2;            /* @@also used as pointer */
  684. {
  685.   rtx temp;
  686.   char *filename;
  687.   int line;
  688.   rtx body = PATTERN (insn);
  689.   rtx asmop;
  690.  
  691.   /* Find the (or one of the) ASM_OPERANDS in the insn.  */
  692.   if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS)
  693.     asmop = SET_SRC (body);
  694.   else if (GET_CODE (body) == ASM_OPERANDS)
  695.     asmop = body;
  696.   else if (GET_CODE (body) == PARALLEL
  697.        && GET_CODE (XVECEXP (body, 0, 0)) == SET)
  698.     asmop = SET_SRC (XVECEXP (body, 0, 0));
  699.   else if (GET_CODE (body) == PARALLEL
  700.        && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS)
  701.     asmop = XVECEXP (body, 0, 0);
  702.  
  703.   filename = ASM_OPERANDS_SOURCE_FILE (asmop);
  704.   line = ASM_OPERANDS_SOURCE_LINE (asmop);
  705.  
  706.   error_with_file_and_line (filename, line, s, v, v2);
  707. }
  708.  
  709. /* Report a warning at line LINE.
  710.    S and V are a string and an arg for `printf'.  */
  711.  
  712. void
  713. warning_with_file_and_line (file, line, s, v, v2)
  714.      char *file;
  715.      int line;
  716.      char *s;
  717.      int v;
  718.      int v2;
  719. {
  720.   if (count_error (1) == 0)
  721.     return;
  722.  
  723.   report_error_function (file);
  724.  
  725.   if (file)
  726. #ifdef MPW
  727.     /* Print file and line so that they're valid MPW commands. */
  728.     fprintf (stderr, "File \"%s\"; Line %d\t# ", file, line);
  729. #else
  730.     fprintf (stderr, "%s:%d: ", file, line);
  731. #endif /* MPW */
  732.   else
  733.     fprintf (stderr, "%s: ", progname);
  734.  
  735.   fprintf (stderr, "warning: ");
  736.   fprintf (stderr, s, v, v2);
  737.   fprintf (stderr, "\n");
  738. }
  739.  
  740. /* Report a warning at the current line number.
  741.    S and V are a string and an arg for `printf'.  */
  742.  
  743. void
  744. warning (s, v, v2)
  745.      char *s;
  746.      int v;            /* @@also used as pointer */
  747.      int v2;
  748. {
  749.   warning_with_file_and_line (input_filename, lineno, s, v, v2);
  750. }
  751.  
  752. /* Report a warning at the declaration DECL.
  753.    S is string which uses %s to substitute the declaration name.
  754.    V is a second parameter that S can refer to.  */
  755.  
  756. void
  757. warning_with_decl (decl, s, v)
  758.      tree decl;
  759.      char *s;
  760.      int v;
  761. {
  762.   if (count_error (1) == 0)
  763.     return;
  764.  
  765.   report_error_function (DECL_SOURCE_FILE (decl));
  766.  
  767. #ifdef MPW
  768.   /* Print file and line so that they're valid MPW commands. */
  769.   fprintf (stderr, "File \"%s\"; Line %d\t# ",
  770. #else
  771.   fprintf (stderr, "%s:%d: ",
  772. #endif /* MPW */
  773.        DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
  774.  
  775.   fprintf (stderr, "warning: ");
  776.   if (DECL_PRINT_NAME (decl))
  777.     fprintf (stderr, s, DECL_PRINT_NAME (decl), v);
  778.   else if (DECL_NAME (decl))
  779.     fprintf (stderr, s, IDENTIFIER_POINTER (DECL_NAME (decl)), v);
  780.   else
  781.     fprintf (stderr, s, "((anonymous))", v);
  782.   fprintf (stderr, "\n");
  783. }
  784.  
  785. /* Apologize for not implementing some feature.
  786.    S, V, and V2 are a string and args for `printf'.  */
  787.  
  788. void
  789. sorry (s, v, v2)
  790.      char *s;
  791.      int v, v2;
  792. {
  793.   sorrycount++;
  794.   if (input_filename)
  795. #ifdef MPW
  796.     /* Print file and line so that they're valid MPW commands. */
  797.     fprintf (stderr, "File \"%s\"; Line %d\t# ", input_filename, lineno);
  798. #else
  799.     fprintf (stderr, "%s:%d: ", input_filename, lineno);
  800. #endif /* MPW */
  801.   else
  802.     fprintf (stderr, "%s: ", progname);
  803.  
  804.   fprintf (stderr, "sorry, not implemented: ");
  805.   fprintf (stderr, s, v, v2);
  806.   fprintf (stderr, "\n");
  807. }
  808.  
  809. /* Apologize for not implementing some feature, then quit.
  810.    S, V, and V2 are a string and args for `printf'.  */
  811.  
  812. void
  813. really_sorry (s, v, v2)
  814.      char *s;
  815.      int v, v2;
  816. {
  817.   if (input_filename)
  818. #ifdef MPW
  819.     /* Print file and line so that they're valid MPW commands. */
  820.     fprintf (stderr, "File \"%s\"; Line %d\t# ", input_filename, lineno);
  821. #else
  822.     fprintf (stderr, "%s:%d: ", input_filename, lineno);
  823. #endif /* MPW */
  824.   else
  825.     fprintf (stderr, "c++: ");
  826.  
  827.   fprintf (stderr, "sorry, not implemented: ");
  828.   fprintf (stderr, s, v, v2);
  829.   fatal (" (fatal)\n");
  830. }
  831.  
  832. /* More 'friendly' abort that prints the line and file.
  833.    config.h can #define abort fancy_abort if you like that sort of thing.  */
  834.  
  835. void
  836. fancy_abort ()
  837. {
  838. #ifdef MPW
  839.   /* Make sure no output still buffered up, then zap into Macsbug. */
  840.   printf("Ack!\n");
  841.   ame = (char *) xmalloc (dump_base_name_length + 6);
  842.       strcpy (dumpname, dump_base_name);
  843.       strcat (dumpname, ".flow");
  844.       flow_dump_file = fopen (dumpname, "w");
  845.       if (flow_dump_file == 0)
  846.     pfatal_with_name (dumpname);
  847.     }
  848.  
  849.   /* If combine dump desired, open the output file.  */
  850.   if (combine_dump)
  851.     {
  852.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
  853.       strcpy (dumpname, dump_base_name);
  854.       strcat (dumpname, ".combine");
  855.       combine_dump_file = fopen (dumpname, "w");
  856.       if (combine_dump_file == 0)
  857.     pfatal_with_name (dumpname);
  858.     }
  859.  
  860.   /* If local_reg dump desired, open the output file.  */
  861.   if (local_reg_dump)
  862.     {
  863.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  864.       strcpy (dumpname, dump_base_name);
  865.       strcat (dumpname, ".lreg");
  866.       local_reg_dump_file = fopen (dumpname, "w");
  867.       if (local_reg_dump_file == 0)
  868.     pfatal_with_name (dumpname);
  869.     }
  870.  
  871.   /* If global_reg dump desired, open the output file.  */
  872.   if (global_reg_dump)
  873.     {
  874.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  875.       strcpy (dumpname, dump_base_name);
  876.       strcat (dumpname, ".greg");
  877.       global_reg_dump_file = fopen (dumpname, "w");
  878.       if (global_reg_dump_file == 0)
  879.     pfatal_with_name (dumpname);
  880.     }
  881.  
  882.   /* If jump2_opt dump desired, open the output file.  */
  883.   if (jump2_opt_dump)
  884.     {
  885.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
  886.       strcpy (dumpname, dump_base_name);
  887.       strcat (dumpname, ".jump2");
  888.       jump2_opt_dump_file = fopen (dumpname, "w");
  889.       if (jump2_opt_dump_file == 0)
  890.     pfatal_with_name (dumpname);
  891.     }
  892.  
  893.   /* If dbr_sched dump desired, open the output file.  */
  894.   if (dbr_sched_dump)
  895.     {
  896.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
  897.       strcpy (dumpname, dump_base_name);
  898.       strcat (dumpname, ".dbr");
  899.       dbr_sched_dump_file = fopen (dumpname, "w");
  900.       if (dbr_sched_dump_file == 0)
  901.     pfatal_with_name (dumpname);
  902.     }
  903.  
  904.   /* Open assembler code output file.  */
  905.  
  906.   if (! name_specified && asm_file_name == 0)
  907.     asm_out_file = stdout;
  908.   else
  909.     {
  910.       register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  911.       int len = strlen (dump_base_name);
  912.       strcpy (dumpname, dump_base_name);
  913. #ifdef MPW
  914.       /* To make a MPW assembly language name, just add a ".a" */
  915.       /* (This really ought to be defined in tm.h ...) */
  916.       strcat (dumpname, ".a");
  917. #else
  918.       if (len > 2 && ! strcmp (".c", dumpname + len - 2))
  919.     dumpname[len - 2] = 0;
  920.       else if (len > 2 && ! strcmp (".i", dumpname + len - 2))
  921.     dumpname[len - 2] = 0;
  922.       else if (len > 3 && ! strcmp (".co", dumpname + len - 3))
  923.     dumpname[len - 3] = 0;
  924.       strcat (dumpname, ".s");
  925. #endif /* MPW */
  926.       if (asm_file_name == 0)
  927.     {
  928.       asm_file_name = (char *) malloc (strlen (dumpname) + 1);
  929.       strcpy (asm_file_name, dumpname);
  930.     }
  931.       if (!strcmp (asm_file_name, "-"))
  932.     asm_out_file = stdout;
  933.       else
  934.     asm_out_file = fopen (asm_file_name, "w");
  935.       if (asm_out_file == 0)
  936.     pfatal_with_name (asm_file_name);
  937.     }
  938.  
  939.   input_filename = name;
  940.  
  941.   /* the beginning of the file is a new line; check for # */
  942.   /* With luck, we discover the real source file's name from that
  943.      and put it in input_filename.  */
  944.   ungetc (check_newline (), finput);
  945.  
  946.   /* If the input doesn't start with a #line, use the input name
  947.      as the official input file name.  */
  948.   if (main_input_filename == 0)
  949.     main_input_filename = name;
  950.  
  951.   /* Put an entry on the input file stack for the main input file.  */
  952.   input_file_stack
  953.     = (struct file_stack *) xmalloc (sizeof (struct file_stack));
  954.   input_file_stack->next = 0;
  955.   input_file_stack->name = input_filename;
  956.  
  957.   ASM_FILE_START (asm_out_file);
  958. #ifdef APPLE_HAX
  959.   /* If the name import machinery is being used, it must be initialized. */
  960.   init_import_for_file();
  961. #endif /* APPLE_HAX */
  962.  
  963.   /* Output something to inform GDB that this compilation was by GCC.  */
  964. #ifndef ASM_IDENTIFY_GCC
  965.   fprintf (asm_out_file, "gcc_compiled.:\n")ifdef DBX_DEBUGGING_INFO
  966.   else if (write_symbols == DBX_DEBUG && TREE_CODE (decl) == TYPE_DECL)
  967.     TIMEVAR (varconst_time, dbxout_symbol (decl, 0));
  968. #endif
  969. #ifdef SDB_DEBUGGING_INFO
  970.   else if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == TYPE_DECL)
  971.     TIMEVAR (varconst_time, sdbout_symbol (decl, 0));
  972. #endif
  973.  
  974.   if (top_level)
  975.     {
  976.       if (write_symbols == GDB_DEBUG)
  977.     {
  978. #ifndef MPW
  979.       /* Don't need gdb symbol output in an MPW environment. */
  980.       TIMEVAR (symout_time,
  981.            {
  982.              /* The initizations make types when they contain
  983.             string constants.  The types are on the temporary
  984.             obstack, so output them now before they go away.  */
  985.              symout_types (get_temporary_types ());
  986.            });
  987. #endif /* n MPW */
  988.     }
  989.       else
  990.     /* Clean out the temporary type list, since the types will go away.  */
  991.     get_temporary_types ();
  992.     }
  993. }
  994.  
  995. /* This is called from finish_function (within yyparse)
  996.    after each top-level definition is parsed.
  997.    It is supposed to compile that function or variable
  998.    and output the assembler code for it.
  999.    After we return, the tree storage is freed.  */
  1000.  
  1001. void
  1002. rest_of_compilation (decl)
  1003.      tree decl;
  1004. {
  1005.   register rtx insns;
  1006.   int start_time = gettime ();
  1007.   int tem;
  1008.  
  1009. #ifdef MPW
  1010.   SpinCursor (1);
  1011. #endif /* MPW */
  1012.   /* If we are reconsidering an inline function
  1013.      at the end of compilation, skip the stuff for making it inline.  */
  1014.  
  1015.   if (DECL_SAVED_INSNS (decl) == 0)
  1016.     {
  1017.  
  1018.       /* If requested, consider whether to make this function inline.  */
  1019.       if (flag_inline_functions || TREE_INLINE (decl))
  1020.     {
  1021.       TIMEVAR (integration_time,
  1022.            {
  1023.              int specd = TREE_INLINE (decl);
  1024.              char *lose = function_cannot_inline_p (decl);
  1025.              if (lose != 0 && specd)
  1026.                warning_with_decl (decl, lose);
  1027.              if (lose == 0)
  1028.                save_for_inline (decl);
  1029.              else
  1030.                TREE_INLINE (decl) = 0;
  1031.            });
  1032.     }
  1033.  
  1034.       insns = get_insns ();
  1035.  
  1036.       /* Dump the rtl code if we are dumping rtl.  */
  1037.  
  1038.       if (rtl_dump)
  1039.     TIMEVAR (dump_time,
  1040.          {
  1041.            fprintf (rtl_dump_file, "\n;; Function %s\n\n",
  1042.                 IDENTIFIER_POINTER (DECL_NAME (decl)));
  1043.            if (DECL_SAVED_INSNS (decl))
  1044.              fprintf (rtl_dump_file, ";; (integrable)\n\n");
  1045.            print_rtl (rtl_dump_file, insns);
  1046.            fflush (rtl_dump_file);
  1047.          });
  1048.  
  1049.       /* If function is inline, and we don't yet know whether to
  1050.      compile it by itself, defer decision till end of compilation.
  1051.      finish_compilation will call rest_of_compilation again
  1052.      for those functions that need to be output.  */
  1053.  
  1054.       if (((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl)
  1055.         && ! flag_keep_inline_functions)
  1056.        || TREE_EXTERNAL (decl))
  1057.       && TREE_INLINE (decl))
  1058.     goto exit_rest_of_compilation;
  1059.  
  1060. #ifdef APPLE_C
  1061.       /* Under no circumstances should we attempt to write out a definition
  1062.      of a direct function. */
  1063.       if (TREE_DIRECT (decl))
  1064.     goto exit_rest_of_compilation;
  1065. #endif /* APPLE_C */
  1066.     }
  1067.   if (rtl_dump_and_exit || flag_syntax_only)
  1068.     {
  1069.       get_temporary_types ();
  1070.       goto exit_rest_of_compilation;
  1071.     }
  1072.  
  1073.   TREE_ASM_WRITTEN (decl) = 1;
  1074.  
  1075.   insns = get_insns ();
  1076.  
  1077.   /* Copy any shared structure that should not be shared.  */
  1078.  
  1079.   unshare_all_rtl (insns);
  1080.  
  1081.   /* See if we have allocated stack slots that are not directly addressable.
  1082.      If so, scan all the insns and create explicit address computation
  1083.      for all references to such slots.  */
  1084. /*   fixup_stack_slots (); */
  1085.  
  1086.   /* Do jump optimization the first time, if -opt.
  1087.      Also do it if -W, but in that case it doesn't change the rtl code,
  1088.      it only computes whether control can drop off the end of the function.  */
  1089.  
  1090.   if (optimize || extra_warnings || warn_return_type
  1091.       /* If function is `volatile', we should warn if it tries to return.  */
  1092.       || TREE_THIS_VOLATILE (decl))
  1093.     TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
  1094. #ifdef MPW
  1095.   SpinCursor (1);
  1096. #endif /* MPW */
  1097.  
  1098.   /* Dump rtl code after jump, if we are doing that.  */
  1099.  
  1100.   if (jump_opt_dump)
  1101.     TIMEVAR (dump_time,
  1102.          {
  1103.            fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
  1104.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1105.            print_rtl (jump_opt_dump_file, insns);
  1106.            fflush (jump_opt_dump_file);
  1107.          });
  1108.  
  1109.   /* Perform common subexpression elimination.
  1110.      Nonzero value from `cse_main' means that jumps were simplified
  1111.      and some code may now be unreachable, so do
  1112.      jump optimization again.  */
  1113.  
  1114.   if (optimize)
  1115.     {
  1116.       TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 0));
  1117.  
  1118.       TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num ()));
  1119.  
  1120.       if (tem)
  1121.     TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
  1122.     }
  1123.  
  1124. #ifdef MPW
  1125.   SpinCursor (1);
  1126. #endif /* MPW */
  1127.   /* Dump rtl code after cse, if we are doing that.  */
  1128.  
  1129.   if (cse_dump)
  1130.     TIMEVAR (dump_time,
  1131.          {
  1132.            fprintf (cse_dump_file, "\n;; Function %s\n\n",
  1133.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1134.            print_rtl (cse_dump_file, insns);
  1135.            fflush (cse_dump_file);
  1136.          });
  1137.  
  1138.   if (loop_dump)
  1139.     TIMEVAR (dump_time,
  1140.          {
  1141.            fprintf (loop_dump_file, "\n;; Function %s\n\n",
  1142.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1143.          });
  1144.  
  1145.   /* Move constant computations out of loops.  */
  1146.  
  1147.   if (optimize)
  1148.     {
  1149.       TIMEVAR (loop_time,
  1150.            {
  1151.          reg_scan (insns, max_reg_num (), 1);
  1152.          loop_optimize (insns, loop_dump ? loop_dump_file : 0);
  1153.            });
  1154.     }
  1155. #ifdef MPW
  1156.   SpinCursor (1);
  1157. #endif /* MPW */
  1158.  
  1159.   /* Dump rtl code after loop opt, if we are doing that.  */
  1160.  
  1161.   if (loop_dump)
  1162.     TIMEVAR (dump_time,
  1163.          {
  1164.            print_rtl (loop_dump_file, insns);
  1165.            fflush (loop_dump_file);
  1166.          });
  1167.  
  1168.   /* Now we choose between stupid (pcc-like) register allocation
  1169.      (if we got the -noreg switch and not -opt)
  1170.      and smart register allocation.  */
  1171.  
  1172.   if (optimize)        /* Stupid allocation probably won't work */
  1173.     obey_regdecls = 0;    /* if optimizations being done.  */
  1174.  
  1175.   regclass_init ();
  1176.  
  1177.   /* Print function header into flow dump now
  1178.      because doing the flow analysis makes some of the dump.  */
  1179.  
  1180.   if (flow_dump)
  1181.     TIMEVAR (dump_time,
  1182.          {
  1183.            fprintf (flow_dump_file, "\n;; Function %s\n\n",
  1184.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1185.          });
  1186.  
  1187.   if (obey_regdecls)
  1188.     {
  1189.       TIMEVAR (flow_time,
  1190.            {
  1191.          regclass (insns, max_reg_num ());
  1192.          stupid_life_analysis (insns, max_reg_num (),
  1193.                        flow_dump_file);
  1194.            });
  1195.     }
  1196.   else
  1197.     {
  1198.       /* Do control and data flow analysis,
  1199.      and write some of the results to dump file.  */
  1200.  
  1201.       TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
  1202.                      flow_dump_file));
  1203.       if (extra_warnings)
  1204.     uninitialized_vars_warning (DECL_INITIAL (decl));
  1205.     }
  1206. #ifdef MPW
  1207.   SpinCursor (1);
  1208. #endif /* MPW */
  1209.  
  1210.   /* Dump rtl after flow analysis.  */
  1211.  
  1212.   if (flow_dump)
  1213.     TIMEVAR (dump_time,
  1214.          {
  1215.            print_rtl (flow_dump_file, insns);
  1216.            fflush (flow_dump_file);
  1217.          });
  1218.  
  1219.   /* If -opt, try combining insns through substitution.  */
  1220.  
  1221.   if (optimize)
  1222.     TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
  1223. #ifdef MPW
  1224.   SpinCursor (1);
  1225. #endif /* MPW */
  1226.  
  1227.   /* Dump rtl code after insn combination.  */
  1228.  
  1229.   if (combine_dump)
  1230.     TIMEVAR (dump_time,
  1231.          {
  1232.            fprintf (combine_dump_file, "\n;; Function %s\n\n",
  1233.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1234.            dump_combine_stats (combine_dump_file);
  1235.            print_rtl (combine_dump_file, insns);
  1236.            fflush (combine_dump_file);
  1237.          });
  1238.  
  1239.   /* Unless we did stupid register allocation,
  1240.      allocate pseudo-regs that are used only within 1 basic block.  */
  1241.  
  1242.   if (!obey_regdecls)
  1243.     TIMEVAR (local_alloc_time,
  1244.          {
  1245.            regclass (insns, max_reg_num ());
  1246.            local_alloc ();
  1247.          });
  1248. #ifdef MPW
  1249.   SpinCursor (1);
  1250. #endif /* MPW */
  1251.  
  1252.   /* Dump rtl code after allocating regs within basic blocks.  */
  1253.  
  1254.   if (local_reg_dump)
  1255.     TIMEVAR (dump_time,
  1256.          {
  1257.            fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
  1258.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1259.            dump_flow_info (local_reg_dump_file);
  1260.            dump_local_alloc (local_reg_dump_file);
  1261.            print_rtl (local_reg_dump_file, insns);
  1262.            fflush (local_reg_dump_file);
  1263.          });
  1264.  
  1265.   if (global_reg_dump)
  1266.     TIMEVAR (dump_time,
  1267.          fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
  1268.               IDENTIFIER_POINTER (DECL_NAME (decl))));
  1269.  
  1270.   /* Unless we did stupid register allocation,
  1271.      allocate remaining pseudo-regs, then do the reload pass
  1272.      fixing up any insns that are invalid.  */
  1273.  
  1274.   TIMEVAR (global_alloc_time,
  1275.        {
  1276.          if (!obey_regdecls)
  1277.            global_alloc (global_reg_dump ? global_reg_dump_file : 0);
  1278.          else
  1279.            reload (insns, 0,
  1280.                global_reg_dump ? global_reg_dump_file : 0);
  1281.        });
  1282. #ifdef MPW
  1283.   SpinCursor (1);
  1284. #endif /* MPW */
  1285.  
  1286.   if (global_reg_dump)
  1287.     TIMEVAR (dump_time,
  1288.          {
  1289.            dump_global_regs (global_reg_dump_file);
  1290.            print_rtl (global_reg_dump_file, insns);
  1291.            fflush (global_reg_dump_file);
  1292.          });
  1293.  
  1294.   rtx_equal_function_value_matters = 1;
  1295.   reload_completed = 1;
  1296.  
  1297.   /* One more attempt to remove jumps to .+1
  1298.      left by dead-store-elimination.
  1299.      Also do cross-jumping this time
  1300.      and delete no-op move insns.  */
  1301.  
  1302.   if (optimize)
  1303.     {
  1304.       TIMEVAR (jump_time, jump_optimize (insns, 1, 1));
  1305.     }
  1306. #ifdef MPW
  1307.   SpinCursor (1);
  1308. #endif /* MPW */
  1309.  
  1310.   /* Dump rtl code after jump, if we are doing that.  */
  1311.  
  1312.   if (jump2_opt_dump)
  1313.     TIMEVAR (dump_time,
  1314.          {
  1315.            fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
  1316.             IDENTIFIER_POINTER (DECL_NAME (decl)));
  1317.            print_rtl (jump2_opt_dump_file, insns);
  1318.            fflush (jump2_opt_dump_file);
  1319.          });
  1320.  
  1321.   /* If a scheduling pass for delayed branches is to be done,
  1322.      call the scheduling code. */
  1323.  
  1324. #ifdef HAVE_DELAYED_BRANCH
  1325.   if (optimize && flag_delayed_branch)
  1326.     {
  1327.       TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file));
  1328.       if (dbr_sched_dump)
  1329.     {
  1330.       TIMEVAR (dump_time,
  1331.          {
  1332.            fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n",
  1333.                 IDENTIFIER_POINTER (DECL_NAME (decl)));
  1334.            print_rtl (dbr_sched_dump_file, insns);
  1335.            fflush (dbr_sched_dump_file);
  1336.          });
  1337.     }
  1338.     }
  1339. #endif
  1340.  
  1341.   /* Now turn the rtl into assembler code.  */
  1342.  
  1343.   TIMEVAR (final_time,
  1344.        {
  1345.          assemble_function (decl);
  1346.          final_start_function (insns, asm_out_file,
  1347.                    write_symbols, optimize);
  1348.          final (insns, asm_out_file,
  1349.             write_symbols, optimize, 0);
  1350.          final_end_function (insns, asm_out_file,
  1351.                  write_symbols, optimize);
  1352.          fflush (asm_out_file);
  1353.        });
  1354. #ifdef MPW
  1355.   SpinCursor (1);
  1356. #endif /* MPW */
  1357.  
  1358.   /* Write GDB symbols if requested */
  1359.  
  1360. #ifndef MPW
  1361.   /* Don't need gdb symbols in an MPW environment. */
  1362.   if (write_symbols == GDB_DEBUG)
  1363.     {
  1364.       TIMEVAR (symout_time,
  1365.            {
  1366.          symout_types (get_permanent_types ());
  1367.          symout_types (get_temporary_types ());
  1368.  
  1369.          DECL_BLOCK_SYMTAB_ADDRESS (decl)
  1370.            = symout_function (DECL_INITIAL (decl),
  1371.                       DECL_ARGUMENTS (decl), 0);
  1372.          symout_function_end ();
  1373.            });
  1374.     }
  1375.   else
  1376. #endif /* n MPW */
  1377.     get_temporary_types ();
  1378.  
  1379.   /* Write DBX symbols if requested */
  1380.  
  1381. #ifdef DBX_DEBUGGING_INFO
  1382.   if (write_symbols == DBX_DEBUG)
  1383.     TIMEVAR (symout_time, dbxout_function (decl));
  1384. #endif
  1385.  
  1386.  exit_rest_of_compilation:
  1387.  
  1388.   rtx_equal_function_value_matters = 0;
  1389.   reload_completed = 0;
  1390.  
  1391.   /* Clear out the real_constant_chain before some of the rtx's
  1392.      it runs through become garbage.  */
  1393.  
  1394.   clear_const_double_mem ();
  1395.  
  1396.   /* The parsing time is all the time spent in yyparse
  1397.      *except* what is spent in this function.  */
  1398.  
  1399.   parse_time -= gettime () - start_time;
  1400. }
  1401.  
  1402. /* Entry point of cc1.  Decode command args, then call compile_file.
  1403.    Exit code is 35 if can't open files, 34 if fatal error,
  1404.    33 if had nonfatal errors, else success.  */
  1405.  
  1406. int
  1407. cc1_main (argc, argv, envp)
  1408.      int argc;
  1409.      char **argv;
  1410.      char **envp;
  1411. {
  1412.   register int i;
  1413.   char *filename = 0;
  1414.   int print_mem_flag = 0;
  1415.   char *p;
  1416.  
  1417. #define INIT_TOPLEV
  1418. #include "init.c"
  1419.   asm_file_name = 0;
  1420.  
  1421.   /* save in case md file wants to emit args as a comment.  */
  1422.   save_argc = argc;
  1423.   save_argv = argv;
  1424.  
  1425. #ifdef APPLE_HAX
  1426.   clear_const_hash_table();
  1427.   clear_type_hash_table();
  1428. #endif
  1429.  
  1430. #ifdef MPW
  1431.   /* Don't bother trying to pick apart program name and full pathname. */
  1432.   p = argv[0];
  1433. #else
  1434.   p = argv[0] + strlen (argv[0]);
  1435.   while (p != argv[0] && p[-1] != '/') --p;
  1436. #endif /* MPW */
  1437.   progname = p;
  1438.  
  1439. #ifdef RLIMIT_STACK
  1440.   /* Get rid of any avoidable limit on stack size.  */
  1441.   {
  1442.     struct rlimit rlim;
  1443.  
  1444.     /* Set the stack limit huge so that alloca does not fail. */
  1445.     getrlimit (RLIMIT_STACK, &rlim);
  1446.     rlim.rlim_cur = rlim.rlim_max;
  1447.     setrlimit (RLIMIT_STACK, &rlim);
  1448.   }
  1449. #endif /* RLIMIT_STACK */
  1450.  
  1451.   signal (SIGFPE, float_signal);
  1452.  
  1453. #ifndef MPW
  1454.   /* No SIGPIPE in MPW. */
  1455.   signal (SIGPIPE, pipe_closed);
  1456. #endif /* n MPW */
  1457.  
  1458. #ifdef MPW
  1459.   /* Prepare to spin the beach ball. */
  1460.   InitCursorCtl (nil);
  1461. #ifdef PERFORMANCE
  1462.   /* Set up some performance analysis stuff. */
  1463.   ThePGlobals = nil;
  1464.   if (!InitPerf (&ThePGlobals,
  1465.          10,  /* 10 ms between samples */
  1466.          16,  /* 16-byte buckets */
  1467.          false, /* ROM code uninteresting to us */
  1468.          true, /* our code interesting */
  1469.          "\pCODE",
  1470.          0,
  1471.          "",
  1472.          false, 0, 0, 0 /* how do RAM misses happen anyway? */
  1473.         ))
  1474.     abort ();
  1475.   PerfControl (ThePGlobals, true);
  1476. #endif /* PERFORMANCE */
  1477. #endif /* MPW */
  1478.  
  1479.   /* Initialize whether `char' is signed.  */
  1480.   flag_signed_char = DEFAULT_SIGNED_CHAR;
  1481. #ifdef DEFAULT_SHORT_ENUMS
  1482.   /* Initialize how much space enums occupy, by default.  */
  1483.   flag_short_enums = DEFAULT_SHORT_ENUMS;
  1484. #endif
  1485.  
  1486.   /* This is zeroed by -O.  */
  1487.   obey_regdecls = 1;
  1488.  
  1489.   /* Initialize register usage now so switches may override.  */
  1490.   init_reg_sets ();
  1491.  
  1492.   target_flags = 0;
  1493.   set_target_switch ("");
  1494.  
  1495.   for (i = 1; i < argc; i++)
  1496.     if (argv[i][0] == '-' && argv[i][1] != 0)
  1497.       {
  1498.     register char *str = argv[i] + 1;
  1499.     if (str[0] == 'Y')
  1500.       str++;
  1501.  
  1502.     if (str[0] == 'm')
  1503.       set_target_switch (&str[1]);
  1504.     else if (!strcmp (str, "dumpbase"))
  1505.       {
  1506.         dump_base_name = argv[++i];
  1507.       }
  1508.     else if (str[0] == 'd')
  1509.       {
  1510.         register char *p = &str[1];
  1511.         while (*p)
  1512.           switch (*p++)
  1513.         {
  1514.         case 'c':
  1515.           combine_dump = 1;
  1516.           break;
  1517.         case 'd':
  1518.           dbr_sched_dump = 1;
  1519.           break;
  1520.         case 'f':
  1521.           flow_dump = 1;
  1522.           break;
  1523.         case 'g':
  1524.           global_reg_dump = 1;
  1525.           break;
  1526.         case 'j':
  1527.           jump_opt_dump = 1;
  1528.           break;
  1529.         case 'J':
  1530.           jump2_opt_dump = 1;
  1531.           break;
  1532.         case 'l':
  1533.           local_reg_dump = 1;
  1534.           break;
  1535.         case 'L':
  1536.           loop_dump = 1;
  1537.           break;
  1538.         case 'm':
  1539.           print_mem_flag = 1;
  1540.           break;
  1541.         case 'r':
  1542.           rtl_dump = 1;
  1543.           break;
  1544.         case 's':
  1545.           cse_dump = 1;
  1546.           break;
  1547.         case 'y':
  1548.           yydebug = 1;
  1549.           break;
  1550.         }
  1551.       }
  1552.     else if (str[0] == 'f')
  1553.       {
  1554.         int j;
  1555.         register char *p = &str[1];
  1556.         int found = 0;
  1557.  
  1558.         /* Some kind of -f option.
  1559.            P's value is the option sans `-f'.
  1560.            Search for it in the table of options.  */
  1561.  
  1562.         for (j = 0;
  1563.          !found && j < sizeof (f_options) / sizeof (f_options[0]);
  1564.          j++)
  1565.           {
  1566.         if (!strcmp (p, f_options[j].string))
  1567.           {
  1568.             *f_options[j].variable = f_options[j].on_value;
  1569.             /* A goto here would be cleaner,
  1570.                but breaks the vax pcc.  */
  1571.             found = 1;
  1572.           }
  1573.         if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
  1574.             && ! strcmp (p+3, f_options[j].string))
  1575.           {
  1576.             *f_options[j].variable = ! f_options[j].on_value;
  1577.             found = 1;
  1578.           }
  1579.           }
  1580.  
  1581.         if (found)
  1582.           ;
  1583.         else if (!strncmp (p, "fixed-", 6))
  1584.           fix_register (&p[6], 1, 1);
  1585.         else if (!strncmp (p, "call-used-", 10))
  1586.           fix_register (&p[10], 0, 1);
  1587.         else if (!strncmp (p, "call-saved-", 11))
  1588.           fix_register (&p[11], 0, 0);
  1589.         else if (! lang_decode_option (argv[i]))
  1590.           error ("Invalid option `%s'", argv[i]);
  1591.       }
  1592.     else if (!strcmp (str, "noreg"))
  1593.       ;
  1594.     else if (!strcmp (str, "opt"))
  1595.       optimize = 1, obey_regdecls = 0;
  1596.     else if (!strcmp (str, "O"))
  1597.       optimize = 1, obey_regdecls = 0;
  1598.     else if (!strcmp (str, "pedantic"))
  1599.       pedantic = 1;
  1600. #ifdef APPLE_C
  1601.     /* Decode the command-line option for supplying a segment name. */
  1602.     else if (!strcmp (str, "s"))
  1603.       segment_name = argv[++i];
  1604.     /* Decode the various forms of the option to generate trace hook calls
  1605.        for the MacApp debugger. */
  1606.     else if (!strcmp (str, "trace"))
  1607.       {
  1608.           char *tracelevel = argv[++i];
  1609.         
  1610.         if (!strcmp (tracelevel, "always"))
  1611.           generate_trace_calls = 1, ignore_trace_pragmas = 1;
  1612.         else if (!strcmp (tracelevel, "on"))
  1613.           generate_trace_calls = 1, ignore_trace_pragmas = 0;
  1614.         else if (!strcmp (tracelevel, "off"))
  1615.           generate_trace_calls = 0, ignore_trace_pragmas = 0;
  1616.         else if (!strcmp (tracelevel, "never"))
  1617.           generate_trace_calls = 0, ignore_trace_pragmas = 1;
  1618.         else
  1619.           {
  1620.               error ("Invalid trace option `%s'", argv[i]);
  1621.           }
  1622.       }
  1623. #endif /* APPLE_C */
  1624.     else if (lang_decode_option (argv[i]))
  1625.       ;
  1626.     else if (!strcmp (str, "quiet"))
  1627.       quiet_flag = 1;
  1628.     else if (!strcmp (str, "version"))
  1629.       {
  1630.         extern char *version_string, *language_string;
  1631.         fprintf (stderr, "%s version %s", language_string, version_string);
  1632. #ifdef TARGET_VERSION
  1633.         TARGET_VERSION;
  1634. #endif
  1635. #ifdef __GNUC__
  1636. #ifndef __VERSION__
  1637. #define __VERSION__ "[unknown]"
  1638. #endif
  1639.         fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__);
  1640. #else
  1641. #ifdef MPW
  1642.         /* Identify the old compiler properly. */
  1643.         fprintf (stderr, " compiled by MPW C.\n");
  1644. #else
  1645.         fprintf (stderr, " compiled by CC.\n");
  1646. #endif /* MPW */
  1647. #endif
  1648.         print_target_switch_defaults ();
  1649.       }
  1650.     else if (!strcmp (str, "w"))
  1651.       inhibit_warnings = 1;
  1652.     else if (!strcmp (str, "W"))
  1653.       extra_warnings = 1;
  1654.     else if (!strcmp (str, "Wunused"))
  1655.       warn_unused = 1;
  1656.     else if (!strcmp (str, "Wshadow"))
  1657.       warn_shadow = 1;
  1658.     else if (!strcmp (str, "Wswitch"))
  1659.       warn_switch = 1;
  1660.     else if (!strncmp (str, "Wid-clash-", 10))
  1661.       {
  1662.         char *endp = str + 10;
  1663.  
  1664.         while (*endp)
  1665.           {
  1666.         if (*endp >= '0' && *endp <= '9')
  1667.           endp++;
  1668.         else
  1669.           error ("Invalid option `%s'", argv[i]);
  1670.           }
  1671.         warn_id_clash = 1;
  1672.         id_clash_len = atoi (str + 10);
  1673.       }
  1674.     else if (!strcmp (str, "p"))
  1675.       profile_flag = 1;
  1676.     else if (!strcmp (str, "a"))
  1677.       {
  1678. #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER)
  1679.         warning ("`-a' option (basic block profile) not supported");
  1680. #else
  1681.         profile_block_flag = 1;
  1682. #endif
  1683.       }
  1684.     else if (!strcmp (str, "gg"))
  1685.       write_symbols = GDB_DEBUG;
  1686. #ifdef DBX_DEBUGGING_INFO
  1687.     else if (!strcmp (str, "g0"))
  1688.       write_symbols = DBX_DEBUG;
  1689.     else if (!strcmp (str, "G0"))
  1690.       write_symbols = DBX_DEBUG;
  1691.     else if (!strcmp (str, "g"))
  1692.       {
  1693.         write_symbols = DBX_DEBUG;
  1694.         use_gdb_dbx_extensions = 1;
  1695.       }
  1696.     else if (!strcmp (str, "G"))
  1697.       {
  1698.         write_symbols = DBX_DEBUG;
  1699.         use_gdb_dbx_extensions = 1;
  1700.       }
  1701. #endif
  1702. #ifdef SDB_DEBUGGING_INFO
  1703.     else if (!strcmp (str, "g"))
  1704.       write_symbols = SDB_DEBUG;
  1705.     else if (!strcmp (str, "G"))
  1706.       write_symbols = SDB_DEBUG;
  1707.     else if (!strcmp (str, "g0"))
  1708.       write_symbols = SDB_DEBUG;
  1709.     else if (!strcmp (str, "G0"))
  1710.       write_symbols = SDB_DEBUG;
  1711. #endif
  1712. #ifndef MPW
  1713.     else if (!strcmp (str, "symout"))
  1714.       {
  1715.         if (write_symbols == NO_DEBUG)
  1716.           write_symbols = GDB_DEBUG;
  1717.         sym_file_name = argv[++i];
  1718.       }
  1719. #endif /* n MPW */
  1720.     else if (!strcmp (str, "o"))
  1721.       {
  1722.         asm_file_name = argv[++i];
  1723.       }
  1724.     else
  1725.       error ("Invalid option `%s'", argv[i]);
  1726.       }
  1727.     else
  1728.       filename = argv[i];
  1729.  
  1730. #ifdef OVERRIDE_OPTIONS
  1731.   /* Some machines may reject certain combinations of options.  */
  1732.   OVERRIDE_OPTIONS;
  1733. #endif
  1734.  
  1735.   /* Now that register usage is specified, convert it to HARD_REG_SETs.  */
  1736.   init_reg_sets_1 ();
  1737.  
  1738.   compile_file (filename);
  1739.  
  1740. #ifdef MPW
  1741.   /* Print out the memory allocation statistics we collected. */
  1742.   if (print_mem_flag)
  1743.     {
  1744.       fprintf (stderr,
  1745.            "%d bytes allocaed, %d bytes mallocked, %d bytes reallocked.\n",
  1746.            totalloca, totmalloc - totalloca, totrealloc);
  1747.       fflush (stderr);
  1748.     }
  1749. #ifdef PERFORMANCE
  1750.   /* Terminate any performance analysis. */
  1751.   PerfDump (ThePGlobals, "", true, 80);
  1752.   TermPerf (ThePGlobals);
  1753. #endif /* PERFORMANCE */
  1754. #else /* not MPW */
  1755. #ifndef USG
  1756. #ifndef VMS
  1757. #ifndef THINK_C
  1758.   if (print_mem_flag)
  1759.     {
  1760.       extern char **environ;
  1761.       char *lim = (char *) sbrk (0);
  1762.  
  1763.       fprintf (stderr, "Data size %d.\n",
  1764.            (int) lim - (int) &environ);
  1765.       fflush (stderr);
  1766.  
  1767.       system ("ps v");
  1768.     }
  1769. #endif
  1770. #endif /* not VMS */
  1771. #endif /* not USG */
  1772. #endif /* MPW */
  1773.  
  1774.   if (errorcount)
  1775.     exit (FATAL_EXIT_CODE);
  1776.   if (sorrycount)
  1777.     exit (FATAL_EXIT_CODE);
  1778.   exit (SUCCESS_EXIT_CODE);
  1779.   return 34;
  1780. }
  1781.  
  1782. /* Decode -m switches.  */
  1783.  
  1784. /* Here is a table, controlled by the tm-...h file, listing each -m switch
  1785.    and which bits in `target_switches' it should set or clear.
  1786.    If VALUE is positive, it is bits to set.
  1787.    If VALUE is negative, -VALUE is bits to clear.
  1788.    (The sign bit is not used so there is no confusion.)  */
  1789.  
  1790. struct {char *name; int value;} target_switches []
  1791.   = TARGET_SWITCHES;
  1792.  
  1793. /* Decode the switch -mNAME.  */
  1794.  
  1795. void
  1796. set_target_switch (name)
  1797.      char *name;
  1798. {
  1799.   register int j;
  1800.   for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
  1801.     if (!strcmp (target_switches[j].name, name))
  1802.       {
  1803.     if (target_switches[j].value < 0)
  1804.       target_flags &= ~-target_switches[j].value;
  1805.     else
  1806.       target_flags |= target_switches[j].value;
  1807.     return;
  1808.       }
  1809.   error ("Invalid option `%s'", name);
  1810. }
  1811.  
  1812. /* Print default target switches for -version.  */
  1813.  
  1814. void
  1815. print_target_switch_defaults ()
  1816. {
  1817.   register int j;
  1818.   register int mask = TARGET_DEFAULT;
  1819.   fprintf (stderr, "default target switches:");
  1820.   for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
  1821.     if (target_switches[j].name[0] != '\0'
  1822.     && target_switches[j].value > 0
  1823.     && (target_switches[j].value & mask) == target_switches[j].value)
  1824.  
  1825.       fprintf (stderr, " -m%s", target_switches[j].name);
  1826.  
  1827.   fprintf (stderr, "\n");
  1828. }
  1829.